package com.cskaoyan.controller.admin.marketmanagement;

import com.cskaoyan.bean.MarketCategory;
import com.cskaoyan.bean.bo.admin.category.CategoryDeleteBo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.vo.admin.category.CategoryListVo;
import com.cskaoyan.service.admin.category.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bwj
 * @Date: 2022/09/07/14:59
 * @Description:商品类目
 */
@RestController
@RequestMapping("admin/category")
public class CategoryController {
    @Autowired
    CategoryService categoryService;

    /**
    * @Author: 宾文杰 @Description: 获取商品类目信息 @Date: 2022/9/7
    */
    @RequestMapping("list")
    public BaseRespVo<CategoryListVo> categoryList(){
        CategoryListVo categoryListVo=categoryService.categoryList();
        return BaseRespVo.ok(categoryListVo);
    }

    /**
    * @Author: 宾文杰 @Description: 创建商品类目 @Date: 2022/9/7
    */
    @RequestMapping("create")
    public BaseRespVo<MarketCategory> categoryCreate(@RequestBody MarketCategory marketCategory){
       MarketCategory category= categoryService.categoryCreate(marketCategory);
       return BaseRespVo.ok(category);
    }

    /**
     * @Author: 宾文杰 @Description: 商品类目信息 @Date: 2022/9/7
     */
    @RequestMapping("l1")
    public BaseRespVo<CategoryListVo> categoryL1(){
        CategoryListVo categoryL1=categoryService.categoryL1();
        return BaseRespVo.ok(categoryL1);
    }

    /**
    * @Author: 宾文杰 @Description: 编辑类目信息 @Date: 2022/9/7
    */
    @RequestMapping("update")
    public BaseRespVo<String> categoryUpdate(@RequestBody MarketCategory marketCategory){
        categoryService.categoryUpdate(marketCategory);
        return BaseRespVo.ok(null);
    }

    /**
    * @Author: 宾文杰 @Description: 删除类目信息 @Date: 2022/9/7
    */
    @RequestMapping("delete")
    public BaseRespVo<String> categoryDelete(@RequestBody CategoryDeleteBo categoryDeleteBo){
        categoryService.categoryDelete(categoryDeleteBo);
        return BaseRespVo.ok(null);
    }
}
